<?php

namespace lc\activity\model;

use think\Model;

class LotteryRedPackConfig extends Model
{
	protected $table = 'lottery_redpack_configs';
    protected $pk = 'l_id';
    protected $autoWriteTimestamp = true;
    protected $createTime = 'l_create_at';
    protected $updateTime = 'l_update_at';

    /**
     * @var 现金红包
     */
    const RED_PACK_TYPE_CASH = 1;

    /**
     * @var 企业支付到零钱红包
     */
    const RED_PACK_TYPE_BALANCE = 2;

	/**
	 * @desc    生成APPID
	 * @return  false|string
	 */
	public static function generateAppId()
	{
		$str   = date('Y', time());
		$chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];

		for ($i = 1; $i <= 8; $i++) {
			$j = rand(0, count($chars) - 1);
			$str .= $chars[$j];
			array_splice($chars, $j, 1);
		}
		return 'rp'.$str;
	}

	/**
	 * @desc    生成SECRET
	 * @param   $appId
	 * @return  string
	 */
	public static function generateAppSecret($appId)
	{
		return sha1($appId);
	}

	public function getLRevcMoneyAttr($value)
	{
		return $value / 100;
	}

	public function getLTotalMoneyAttr($value)
	{
		return $value / 100;
	}
}